<template>
  <div>
    <detail-header :detailTitle="detailTitle"></detail-header>
    <detail-banner :detailTitle="detailTitle" :bannerImgUrl="bannerImgUrl" :galleryImgUrls="galleryImgUrls"></detail-banner>
    <detail-list :detailList = detailList></detail-list>
  </div>
</template>

<script type="text/ecmascript-6">
import DetailHeader from './component/header'
import DetailBanner from './component/banner'
import DetailList from './component/list'
import axios from 'axios'
export default {
  name: 'Detail',
  data () {
    return {
      detailTitle: '',
      bannerImgUrl: '',
      galleryImgUrls: [],
      detailList: []
    }
  },
  components: {
    DetailHeader,
    DetailBanner,
    DetailList
  },
  methods: {
    getDetailInfo () {
      axios.get('/api/detail.json', {
        params: {
          id: this.$route.params.id
        }
      }).then(this.getDetailInfoSuc)
    },
    getDetailInfoSuc (res) {
      const resData = res.data
      if (resData.ret && resData.data) {
        const data = resData.data
        this.detailTitle = data.sightName
        this.bannerImgUrl = data.bannerImg
        this.galleryImgUrls = data.gallaryImgs
        this.detailList = data.categoryList
      }
    }
  },
  mounted () {
    this.getDetailInfo()
  }
}
</script>

<style lang="scss" scoped>

</style>
